package com.example.demo04.mapper;

import com.example.demo04.domain.ManagerFenceHouse;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ManagerFenceHouseMapper {
    // 1. 新增栏舍（需传入fhId、fhName、fhDesc、fhTime）
    @Insert("INSERT INTO manager_fence_house (fh_id, fh_name, fh_desc, fh_time) " +
            "VALUES (#{fhId}, #{fhName}, #{fhDesc}, #{fhTime})")
    void insertFenceHouse(ManagerFenceHouse fenceHouse);

    // 2. 根据id删除栏舍
    @Delete("DELETE FROM manager_fence_house WHERE fh_id = #{fhId}")
    void deleteFenceHouseById(String fhId);

    // 3. 修改栏舍（不修改fh_time，只更新name和desc）
    @Update("UPDATE manager_fence_house " +
            "SET fh_name = #{fhName}, fh_desc = #{fhDesc} " +
            "WHERE fh_id = #{fhId}")
    void updateFenceHouse(ManagerFenceHouse fenceHouse);

    // 4. 根据id查询栏舍
    @Select("SELECT fh_id AS fhId, fh_name AS fhName, fh_desc AS fhDesc, fh_time AS fhTime " +
            "FROM manager_fence_house WHERE fh_id = #{fhId}")
    ManagerFenceHouse selectFenceHouseById(String fhId);

    // 5. 查询所有栏舍
    @Select("SELECT fh_id AS fhId, fh_name AS fhName, fh_desc AS fhDesc, fh_time AS fhTime " +
            "FROM manager_fence_house")
    List<ManagerFenceHouse> selectAllFenceHouses();
}
